<div class="content">
<%=render :partial=>"breadcrumb"%>
</br>

<div class="edit_photo">
<h1><%= _('New photo') %></h1>

    <%= error_messages_for "photo" %>
    <%= start_form_tag nil, :multipart=>true %>

            
        <div class="form_cover">
            <span class="form_left"><label><%= _('Title') %></label></span>
            <span class="form_right"><%= text_field_tag :name, @params[:name], {"size"=>"30"} %></span>
        </div>              
        <div class="form_cover">
            <span class="form_left"><label><%= _('Description') %></label></span>
            <span class="form_right"><%= text_field "photo", "description" %></span>
        </div>              
        <div class="form_cover">
            <span class="form_left"><label for="tags" ><%= _('Tag') %></label></span>
            <span class="form_right"><%= text_field_tag  :tags, @params[:tags], {"size"=>"30", "id"=>"tagfield"}  %></span>
            <div class="auto_complete" id="tags_auto_complete" ></div>
            <%= auto_complete_field :tags, :url=>{:action=>"autocomplete_add_new_tags"}, :tokens => ',' %>
        </div>              
        <div class="form_cover">
            <span class="form_left"><label><%= _('Photo') %></label></span>
            <span class="form_right"><%= file_field_tag 'file',{"size"=>"17"}%></span>
        </div>
        <br/>
        <script type="text/javascript">
           function fullfil(title){
               if(document.getElementById('tagfield').value != "")
	               document.getElementById('tagfield').value = document.getElementById('tagfield').value +','+title;
	           else 
	               document.getElementById('tagfield').value = document.getElementById('tagfield').value +title;	           		
         }
        </script>
        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
        <%= submit_tag _("Upload") %>
<%= 
        button_to_function "Cancel" do |page|
        page.redirect_to :controller => "admin", :action => "album_page", :id =>@album.id
        end
 %>
         
        
        <br/><br/><br/>

        <h2><%= _('Existing tags') %></h2>
        <div id="tags_update">
        
        <%tags=Tag.find :all, :order=>"title"%>
        <% comma = 0 %>
        <%tags.each do |t|%>
        <% comma = comma+1 %>
        <%=link_to_function "[#{t.title}]", "fullfil('#{t.title}')" %>
        <% if comma!=tags.length%>
        <%=", "%>
        <%end%>
        <%end%>
        </div>
        
    <%= end_form_tag %>
    
        </div>
        </div>
